<template>
    <div class="processMsgBox">
        <modal
            v-model="value"
            ref="msgModal"
            :label-width="80"
            :closable="false"
            :mask-closable='false'
            :width="modalWidth"
            :styles="{top: '180px'}">
            <div slot="header" style="text-align: center;font-size: 24px;font-weight: bolder;">
                {{messageTitle}}
            </div>
            <Form ref="messageForm" :model="formData" inline :label-width="labelWidth">
                <Form-item label="退回原因" prop="message">
                    <textarea v-model="formData.approveMessage" type="textarea" :rows="4" style="width: 400px;height: 100px;line-height: 20px"
                              placeholder="请输入退回原因" maxlength="512"/>
                </Form-item>
            </Form>
            <div slot="footer">
                <Button type="primary" @click="save">提交</Button>
                <Button type="text" @click="cancel">关闭</Button>
            </div>
        </modal>
    </div>
</template>

<script>
    import {saveReturnReason} from "../../../../api/afs-case/approve/reconsideration";
    export default {
        name: "returnReason",
        props: {
            value: {
                type: Boolean,
                default: false
            },
            messageTitle: {
                type: String,
                default: '退回原因'
            },
            modalWidth: {
                type: Number,
                default: 700
            },
            labelWidth: {
                type: Number,
                default: 150
            },
            returnRea: {
                type: Object,
                default: () => {
                    return {
                        applyNo: '',
                        stageId: '',
                    };
                }
            },
        },
        data() {
            return {
                formData: {
                    approveMessage: []
                },
                typeData: [],
                reasonVisible:true,
                approveSuggest:'sendBack',
                approveSuggestName: '退回'
            }
        },
        methods: {
            cancel() {
                this.$emit('input', false);
                this.$emit('cancel');
            },
            save() {
                if(this.formData.approveMessage == ""){
                    this.$Message.warning("请书写退回内容");
                    return;
                }
                let params = {
                    applyNo: this.returnRea.applyNo,
                    stageId: this.returnRea.stageId,
                    approveRemark: this.formData.approveMessage,
                    approveSuggest:this.approveSuggest,
                    approveSuggestName:this.approveSuggestName
                };
                saveReturnReason(params).then(res=>{
                    if(res.code == "0000"){
                        this.$Message.info("保存成功!")
                        this.$emit('shutdown', false);
                        window.close();
                    }
                })
            },
        },
        mounted() {
        }
    }
</script>

<style scoped>

</style>
